<template>
  <el-dialog :title="title"
             :visible.sync="visible"
             v-loading="loading"
             :before-close="modalClose"
             :close-on-click-modal="false"
             :close-on-press-escape="false"
             width="90%">
    <el-form ref="formRef"
             :model="formModel"
             :rules="formRules"
             label-width="180px">

      <el-row>
        <el-col :span="12">
          <el-form-item label="所属分类：" class="is-required">
            <el-select v-model="formModel.diseaseClassificationId"
                       clearable
                       filterable
                       class="w-300"
                       placeholder="请选择分类">
              <el-option v-for="item in departments"
                         :key="item.id"
                         :label="item.name"
                         :value="item.id">
              </el-option>
            </el-select>
          </el-form-item>

        </el-col>
        <el-col :span="12">
          <el-form-item label="主题名称："
                        prop="name">
            <el-input v-model="formModel.name"
                      placeholder="请输入主题名称"
                      class="w-300"></el-input>
          </el-form-item>

        </el-col>
      </el-row>

      <el-row>
        <el-col :span="12">
          <el-form-item label="关联主症："
                        prop="drugDiseaseTypeId">
            <el-select v-model="formModel.drugDiseaseTypeId"
                       placeholder="请选择关联主症"
                       filterable
                       remote
                       clearable
                       reserve-keyword
                       :remote-method="(query) => {remoteMethod(query, 'drugDisease')}"
                       :loading="loading1"
                       class="w-300"
                       @change="val=>handleSelect(val, 'drugDisease')"
                       :disabled="dataObj ? true : false">
              <el-option v-for="item in associateFilterList"
                         :key="item.id"
                         :label="item.name"
                         :value="item.id">
              </el-option>
            </el-select>
          </el-form-item>

        </el-col>
        <el-col :span="12">
          <el-form-item label="合并症："
                        prop="complicationId">
            <el-select v-model="formModel.complicationId"
                       placeholder="请选择合并症"
                       filterable
                       remote
                       clearable
                       reserve-keyword
                       :remote-method="(query) => {remoteMethod(query, 'complication')}"
                       :loading="loading2"
                       class="w-300"
                       @change="val=>handleSelect(val, 'complication')">
              <el-option v-for="item in complicationFilterList"
                         :key="item.id"
                         :label="item.name"
                         :value="item.id">
              </el-option>
            </el-select>

          </el-form-item>

        </el-col>
      </el-row>

      <el-row>
        <el-col :span="12">
          <el-form-item label="推荐健康地图病种：" prop="themeHealthMapDiseases">
            <el-select v-model="formModel.themeHealthMapDiseases"
                       clearable
                       filterable
                       value-key="healthMapDiseaseId"
                       multiple
                       class="w-300"
                       placeholder="请选择病种">
              <el-option v-for="item in diseaseList"
                         :key="item.healthMapDiseaseId"
                         :label="item.healthMapDiseaseName"
                         :value="item">
              </el-option>
            </el-select>

          </el-form-item>

        </el-col>
        <el-col :span="12">
          <el-form-item label="是否为慢病专病病种:">
            <el-radio-group v-model="formModel.isChronicDisease">
              <el-radio :label="0">否</el-radio>
              <el-radio :label="1">是</el-radio>
            </el-radio-group>
          </el-form-item>

        </el-col>
      </el-row>

      <!--      <el-form-item label="对应量表：" prop="scaleIds"-->
      <!--                    :rules="formModel.isChronicDisease==1?formRules.scaleIds:[{required: false}]"-->
      <!--                    v-if="formModel.isChronicDisease==1">-->
      <!--        <el-select v-model="formModel.scaleIds"-->
      <!--                   clearable-->
      <!--                   multiple-->
      <!--                   filterable-->
      <!--                   style="width: 260px"-->
      <!--                   placeholder="请选择量表">-->
      <!--          <el-option v-for="item in scaleList"-->
      <!--                     :key="item.id"-->
      <!--                     :label="item.scaleName"-->
      <!--                     :value="item.id">-->
      <!--          </el-option>-->
      <!--        </el-select>-->
      <!--      </el-form-item>-->

      <el-row>
        <el-col :span="12">
          <el-form-item label="对应科室：" prop="departmentIds"
                        :rules="formModel.isChronicDisease==1?formRules.departmentIds:[{required: false}]"
                        v-if="formModel.isChronicDisease==1">
            <el-select v-model="formModel.departmentIds"
                       clearable
                       multiple
                       filterable
                       class="w-300"
                       placeholder="请选择科室">
              <el-option v-for="item in departmentList"
                         :key="item.id"
                         :label="item.name"
                         :value="item.id">
              </el-option>
            </el-select>
          </el-form-item>

        </el-col>
        <el-col :span="12">
          <el-form-item label="检测产品价格："
                        v-if="formModel.isChronicDisease===1"
                        prop="themeProduct.price">
            <el-input v-model="formModel.themeProduct.price"
                      placeholder="请输入检测产品价格"
                      class="w-300">
              <el-button slot="append">元</el-button>
            </el-input>
          </el-form-item>

        </el-col>
      </el-row>
      <el-form-item label="关联对应健康地图病种：">
        <el-select v-model="formModel.healthMapDiseaseId"
                   clearable
                   filterable
                   class="w-300"
                   placeholder="请选择关联对应健康地图病种">
          <el-option v-for="item in diseaseList"
                     :key="item.healthMapDiseaseId"
                     :label="item.healthMapDiseaseName"
                     :value="item.healthMapDiseaseId">
          </el-option>
        </el-select>
      </el-form-item>


      <el-form-item label="风险初筛主题病症推荐：" v-if="formModel.isChronicDisease===1">
        <el-tree
          :data="slowList"
          show-checkbox
          node-key="id"
          :default-checked-keys="defaultCheckedKeys"
          :props="defaultProps"
          @check="handleCheckChange">
        </el-tree>
      </el-form-item>
      <el-form-item label="店员检测费用："
                    v-if="formModel.isChronicDisease===1"
                    prop="themeProduct.detectAward">
        <el-input v-model="formModel.themeProduct.detectAward"
                  placeholder="请输入店员检测费用"
                  class="w-300">
          <el-button slot="append">元</el-button>
        </el-input>
      </el-form-item>


      <el-form-item label="病症知识点：">
        <div>
          <vue-neditor-wrap :destroy="false"
                            v-model="formModel.knowledgePoints"
                            :config="myConfig"></vue-neditor-wrap>

        </div>
      </el-form-item>

      <el-form-item label="组包参考：" v-if="formModel.isChronicDisease==1"
                    prop="packageReference">
        <div>
          <vue-neditor-wrap :destroy="false"
                            v-model="formModel.packageReference"
                            :config="myConfig"></vue-neditor-wrap>

        </div>
      </el-form-item>

      <el-form-item label="必测检测项：">

        <el-button type="primary"
                   @click="handleAddItem(maxNum++)">新 增
        </el-button>
        <!-- 全测指标 S -->
        <el-card class="card-box mt-20">
          <div slot="header">
            <span>全测指标：</span>
            <el-select v-model="everyDetectIds"
                       placeholder="请选择检测项"
                       filterable
                       remote
                       clearable
                       reserve-keyword
                       :remote-method="(query) => {remoteMethod2(query, 'everyItem')}"
                       :loading="loading44"
                       class="w-200"
                       @change="val=>handleSelect2(val, 'everyItem')">
              <el-option v-for="item in detectFilterList"
                         :key="item.id"
                         :label="item.name"
                         :value="item.id">
              </el-option>
            </el-select>
            <el-button type="primary"
                       @click="handleAddSelectVal(everyDetectIds, 'everyItem')">新 增
            </el-button>
          </div>
          <el-table :data="themeDeviceTableList1"
                    style="width: 100%"
                    border
                    :span-method="handleSpan">
            <el-table-column prop="deviceName"
                             label="检测项名称">
            </el-table-column>
            <el-table-column prop="referenceName"
                             label="检测指标">
            </el-table-column>
            <el-table-column prop="referenceValue"
                             label="参考值">
              <template slot-scope="scope">
                <el-input v-model="scope.row.referenceValue"
                          placeholder="请输入参考值"
                          class="w-200"></el-input>
              </template>
            </el-table-column>
            <el-table-column prop="delField"
                             label="操作"
                             width="100"
                             align="center">
              <template slot-scope="scope">
                <el-button type="danger"
                           @click="delMergeRow(themeDeviceTableList1, scope.row, 'everyItem')">删 除
                </el-button>
              </template>
            </el-table-column>
          </el-table>
        </el-card>
        <!-- 全测指标 E -->
        <!-- 任选X项 S -->
        <div v-for="(item, index) in themeDeviceTable"
             :key="index">
          <el-card class="card-box mt-20">
            <div slot="header"
                 class="clearfix">
              <span class="fill-box">任选<el-input-number v-model="item.num"
                                                        :controls="false"
                                                        class="num"
                                                        @change="changeItemVal"></el-input-number> 项：</span>
              <el-select v-model="item.someDetectIds"
                         placeholder="请选择检测项"
                         filterable
                         remote
                         clearable
                         reserve-keyword
                         :remote-method="(query) => {remoteMethod2(query, 'someItem')}"
                         :loading="loading33"
                         class="w-200"
                         @change="val=>handleSelect2(val, 'someItem')">
                <el-option v-for="el in detectFilterList"
                           :key="el.id"
                           :label="el.name"
                           :value="el.id">
                </el-option>
              </el-select>
              <el-button type="primary"
                         @click="handleAddSelectVal(item.someDetectIds, 'someItem', index, item.num, item.modelIndex)">
                新增检测项
              </el-button>
              <el-button type="danger"
                         style="float: right;"
                         @click="delRowItem(themeDeviceTable,  'someItem', index, item.num)">删除检测项
              </el-button>
            </div>
            <div v-if="item.themeDeviceDtoList">
              <el-table :data="item.themeDeviceDtoList"
                        style="width: 100%"
                        border
                        :key="index"
                        :span-method="handleSpan">
                <el-table-column prop="deviceName"
                                 label="检测项名称">
                </el-table-column>
                <el-table-column prop="referenceName"
                                 label="检测指标">
                </el-table-column>
                <el-table-column prop="referenceValue"
                                 label="参考值">
                  <template slot-scope="scope">
                    <el-input v-model="scope.row.referenceValue"
                              placeholder="请输入参考值"
                              class="w-200"></el-input>
                  </template>
                </el-table-column>
                <el-table-column prop="delField"
                                 label="操作"
                                 width="100"
                                 align="center">
                  <template slot-scope="scope">
                    <el-button type="danger"
                               @click="delMergeRow(item.themeDeviceDtoList, scope.row, 'someItem', index)">删 除
                    </el-button>
                  </template>
                </el-table-column>
              </el-table>
            </div>
          </el-card>
        </div>
        <!-- 任选X项 E -->
      </el-form-item>
      <el-form-item label="相关检测项："
                    prop="detectIds">
        <el-select v-model="detectIds"
                   placeholder="请选择相关检测项"
                   filterable
                   remote
                   clearable
                   reserve-keyword
                   :remote-method="(query) => {remoteMethod2(query, 'detect')}"
                   :loading="loading55"
                   class="w-200"
                   @change="val=>handleSelect2(val, 'detect')">
          <el-option v-for="item in detectFilterList"
                     :key="item.id"
                     :label="item.name"
                     :value="item.id">
          </el-option>
        </el-select>
        <!-- 相关检测项 S -->
        <el-button type="primary"
                   @click="handleAddSelectVal(detectIds, 'detect')">新 增
        </el-button>
        <el-card class="card-box mt-20">
          <div slot="header"><span>相关检测项</span></div>
          <el-table :data="correlationDtoList"
                    style="width: 100%"
                    border
                    :span-method="handleSpan">
            <el-table-column prop="deviceName"
                             label="检测项名称">
            </el-table-column>
            <el-table-column prop="referenceName"
                             label="检测指标">
            </el-table-column>
            <el-table-column prop="referenceValue"
                             label="参考值">
              <template slot-scope="scope">
                <el-input v-model="scope.row.referenceValue"
                          placeholder="请输入参考值"
                          class="w-200"></el-input>
              </template>
            </el-table-column>

            <el-table-column prop="delField"
                             label="操作"
                             width="100"
                             align="center">
              <template slot-scope="scope">
                <el-button type="danger"
                           @click="delMergeRow(correlationDtoList, scope.row, 'detect')">删 除
                </el-button>
              </template>
            </el-table-column>
          </el-table>
        </el-card>
        <!-- 相关检测项 E -->
      </el-form-item>
      <el-form-item label="推荐健康风险筛查项目："
                    prop="riskIds"
                    label-width="180px">
        <el-select v-model="riskIds"
                   placeholder="请选择健康风险筛查项目"
                   filterable
                   remote
                   reserve-keyword
                   clearable
                   :remote-method="(query) => {remoteMethod2(query, 'risk')}"
                   :loading="loading4"
                   class="w-200"
                   @change="val=>handleSelect2(val, 'risk')">
          <el-option v-for="item in riskFilterList"
                     :key="item.healthCheckPackageId"
                     :label="item.name"
                     :value="item.healthCheckPackageId">
          </el-option>
        </el-select>
        <el-button type="primary"
                   @click="handleAddSelectVal(riskIds, 'risk')">新 增
        </el-button>
      </el-form-item>
      <el-form-item label="已选健康筛查项目："
                    label-width="140px">
        <el-table :data="formModel.themeHealthDtoList"
                  style="width: 100%"
                  border>
          <el-table-column prop="name"
                           label="健康筛查项目"
                           width="300">
          </el-table-column>
          <el-table-column prop="salesScript"
                           label="销售导语">
            <template slot-scope="scope">
              <el-input v-model="scope.row.salesScript"
                        placeholder="请输入销售导语"
                        type="textarea"></el-input>
            </template>
          </el-table-column>
          <el-table-column prop="option"
                           label="操作"
                           width="100"
                           align="center">
            <template slot-scope="scope">
              <el-button type="danger"
                         @click="delRow(formModel.themeHealthDtoList, scope.$index)">删 除
              </el-button>
            </template>
          </el-table-column>
        </el-table>
      </el-form-item>
      <!-- 推荐器械 -->
      <el-form-item label="推荐器械：">
        <el-button type="primary"
                   @click="handleAdd('equipment')">新 增
        </el-button>
        <el-table :data="formModel.apparatusRequestDtoList"
                  style="width: 100%"
                  border
                  class="mt-20">
          <el-table-column prop="drugName"
                           label="器械名称">
          </el-table-column>
          <el-table-column prop="logoUrl"
                           label="图片"
                           width="120"
                           align="center">
            <template slot-scope="scope">
              <el-image style="width: 80px; height: 80px"
                        :src="scope.row.logoUrl"
                        :preview-src-list="[scope.row.logoUrl]">
              </el-image>
            </template>
          </el-table-column>
          <el-table-column prop="salesScript"
                           label="销售导语">
          </el-table-column>
          <el-table-column prop="option"
                           label="操作"
                           width="150"
                           align="center">
            <template slot-scope="scope">
              <el-button type="danger"
                         @click="delRow(formModel.apparatusRequestDtoList, scope.$index, 'equipment')">删 除
              </el-button>
            </template>
          </el-table-column>
        </el-table>
        <equipment-dialog :equipmentDataObj="equipmentDataObj"
                          :equipmentDataList="formModel.apparatusRequestDtoList"
                          @childEquipmentData="childEquipmentData"
                          :visible.sync="isShowEquipment"
                          v-if="isShowEquipment"></equipment-dialog>
      </el-form-item>
      <!-- 推荐商品 -->
      <el-form-item label="推荐商品：">
        <el-button type="primary"
                   @click="handleAdd('shop')">新 增
        </el-button>
        <el-table :data="formModel.sellDrugDtoList"
                  style="width: 100%"
                  border
                  class="mt-20">
          <el-table-column prop="drugType"
                           label="商品类别"
                           align="center"
                           width="120">
            <template slot-scope="scope">
              <el-tag type="success"
                      v-if="scope.row.drugType === 1">中药
              </el-tag>
              <el-tag type="success"
                      v-if="scope.row.drugType === 2">化学药
              </el-tag>
              <el-tag type="danger"
                      v-if="scope.row.drugType === 3">中成药
              </el-tag>
              <el-tag type="info"
                      v-if="scope.row.drugType === 4">保健品
              </el-tag>
              <el-tag type="warning"
                      v-if="scope.row.drugType === 5">器械
              </el-tag>
              <el-tag type="success"
                      v-if="scope.row.drugType === 6">健康筛查
              </el-tag>
            </template>
          </el-table-column>
          <el-table-column prop="drugName"
                           label="商品名称">
          </el-table-column>
          <el-table-column prop="logoUrl"
                           label="图片"
                           width="120"
                           align="center">
            <template slot-scope="scope">
              <el-image style="width: 80px; height: 80px"
                        :src="scope.row.logoUrl"
                        :preview-src-list="[scope.row.logoUrl]">
              </el-image>
            </template>
          </el-table-column>
          <el-table-column prop="standard"
                           label="规格"
                           width="100"
                           align="center">
          </el-table-column>
          <el-table-column prop="drugPackage"
                           label="包装"
                           width="100"
                           align="center">
          </el-table-column>
          <el-table-column prop="functionalIndications"
                           label="功能主治">
          </el-table-column>
          <el-table-column prop="taboo"
                           label="禁忌">
          </el-table-column>
          <el-table-column prop="adverseReaction"
                           label="不良反应">
          </el-table-column>
          <el-table-column prop="salesScript"
                           label="销售话术">
          </el-table-column>
          <el-table-column prop="option"
                           label="操作"
                           width="120"
                           align="center">
            <template slot-scope="scope">
              <el-button type="danger"
                         @click="delRow(formModel.sellDrugDtoList, scope.$index, 'shop')">删 除
              </el-button>
            </template>
          </el-table-column>
        </el-table>
        <shop-dialog :shopDataObj="shopDataObj"
                     :fileUpload="fileUpload"
                     :sellDrugDtoList="formModel.sellDrugDtoList"
                     @childShopData="childShopData"
                     :visible.sync=isShowShop
                     v-if="isShowShop">
        </shop-dialog>
      </el-form-item>
      <!-- 联合荐药 -->
      <el-form-item label="联合荐药：">
        <el-button type="primary"
                   @click="handleAdd('medicine')">新 增
        </el-button>
        <el-table :data="recommendMedicineRequestDtoList"
                  style="width: 100%"
                  border
                  class="mt-20">
          <el-table-column prop="drugType"
                           label="类别"
                           width="120">
            <template slot-scope="scope">
              <el-tag type="success"
                      v-if="scope.row.drugType === 2">化学药
              </el-tag>
              <el-tag type="dager"
                      v-if="scope.row.drugType === 3">中成药
              </el-tag>
              <el-tag type="warning"
                      v-if="scope.row.drugType === 4">保健品
              </el-tag>
              <el-tag type="info"
                      v-if="scope.row.drugType === 5">器械
              </el-tag>
              <el-tag type="dager"
                      v-if="scope.row.drugType === 6">健康筛查
              </el-tag>
            </template>
          </el-table-column>
          <el-table-column prop="value"
                           label="内容">
            <template slot-scope="scope">
              <el-tag type="success"
                      v-for="(item, index) in scope.row.value"
                      :key="index"
                      style="margin-right:5px">
                {{ item.drugName }}--{{ item.factoryName }}
              </el-tag>
            </template>
          </el-table-column>
        </el-table>
        <table style="width: 100%"
               border="0"
               class="table-cell"
               cellspacing="0"
               cellpadding="0">
          <tr>
            <td width="121"
                class="first-td">
              <el-tag type="danger">健康筛查项目</el-tag>
            </td>
            <td>
              <el-tag v-for="item in formModel.themeHealthDtoList"
                      :key="item.id"
                      type="danger"
                      style="margin-right:5px">
                {{ item.name }}
              </el-tag>
            </td>
          </tr>
          <tr>
            <td width="121"
                class="first-td">
              <el-tag type="info">销售话术</el-tag>
            </td>
            <td>
              {{ formModel.recommendSalesScript }}
            </td>
          </tr>
        </table>
        <medicine-dialog :medicineDataObj="medicineDataObj"
                         @childMedicineData="childMedicineData"
                         :visible.sync="isShowMedicine"
                         v-if="isShowMedicine"></medicine-dialog>
      </el-form-item>
      <el-form-item label="推荐医院检查项目："
                    prop="recommendableProjects">
        <el-input v-model="formModel.recommendableProjects"
                  placeholder="请输入推荐医院检查项目"
                  type="textarea"
                  style="calc(100% - 150px)"></el-input>
      </el-form-item>
      <el-form-item label="防治与康养：" v-if="formModel.themeDrugNotice">
        <div>
          <vue-neditor-wrap :destroy="true"
                            v-model="formModel.themeDrugNotice.prevention"
                            :config="myConfig"></vue-neditor-wrap>
        </div>
      </el-form-item>
      <!-- 重点知识点 -->
      <el-form-item label="重点知识点：">
        <el-button type="primary"
                   @click="handleAdd('goods')">新 增
        </el-button>
        <p align="center"
           style="width:100%"
           v-if="goodsList.length === 0">
          <el-empty :image-size="100"></el-empty>
        </p>
        <el-card class="mt-20 knowledge-box"
                 v-else>
          <el-timeline>
            <el-timeline-item class="div-list"
                              v-for="(item, index) in goodsList"
                              :key="index">
              <div class="knowledge-main">
                <span v-html="commonFunction.highLight1(item.knowledge, item.keyWordList)">{{ item.knowledge }}</span>
                <el-button type="primary"
                           @click="editRow(goodsList, index, 'goods')">编 辑
                </el-button>
                <el-button type="danger"
                           @click="removeRow(goodsList, index, 'goods')">删 除
                </el-button>
              </div>
              <ul v-if="item.knowledgeImage"
                  class="knowledgeImage-list">
                <li v-for="(list, i) in item.knowledgeImage"
                    :key="i">
                  <el-image style="width: 120px; height: 120px"
                            :src="list"
                            :preview-src-list="item.knowledgeImage">
                  </el-image>
                  <i class="del el-icon-error"
                     @click="removeRow(item.knowledgeImage, i)"></i>

                </li>
              </ul>
            </el-timeline-item>
          </el-timeline>
        </el-card>

        <goods-dialog :goodsDataObj="goodsDataObj"
                      @childGoodsData="childGoodsData"
                      :isShowDetail="isShowDetail"
                      :visible.sync="isShowGoods"
                      v-if="isShowGoods"></goods-dialog>
      </el-form-item>
      <!-- 关联知识点 -->
      <el-form-item label="关联知识点：">
        <el-button type="primary"
                   @click="handleAdd('knowledge')">新 增
        </el-button>
        <p align="center"
           style="width:100%"
           v-if="knowledgeList.length === 0">
          <el-empty :image-size="100"></el-empty>
        </p>
        <el-card class="mt-20 knowledge-box"
                 v-else>
          <el-timeline>
            <el-timeline-item class="div-list"
                              v-for="(item, index) in knowledgeList"
                              :key="index">
              <div class="knowledge-main">
                <span v-html="commonFunction.highLight1(item.knowledge, item.keyWordList)">{{ item.knowledge }}</span>
                <el-button type="primary"
                           @click="editRow(knowledgeList, index, 'knowledge')">编 辑
                </el-button>
                <el-button type="danger"
                           @click="removeRow(knowledgeList, index, 'knowledge')">删 除
                </el-button>
              </div>
              <ul v-if="item.knowledgeImage"
                  class="knowledgeImage-list">
                <li v-for="(list, i) in item.knowledgeImage"
                    :key="i">
                  <el-image style="width: 120px; height: 120px"
                            :src="list"
                            :preview-src-list="item.knowledgeImage">
                  </el-image>
                  <i class="del el-icon-error"
                     @click="removeRow(item.knowledgeImage, i)"></i>
                </li>
              </ul>
            </el-timeline-item>
          </el-timeline>
        </el-card>
        <knowledge-dialog :knowledgeDataObj="knowledgeDataObj"
                          @childKnowledgeData="childKnowledgeData"
                          :isShowDetail="isShowDetail"
                          :visible.sync="isShowKnowledge"
                          v-if="isShowKnowledge"></knowledge-dialog>
      </el-form-item>

      <el-form-item label="用药指导：" v-if="formModel.themeDrugNotice">
          <vue-neditor-wrap :destroy="false"
                            v-model="formModel.themeDrugNotice.drugRefer"
                            :config="myConfig"></vue-neditor-wrap>

      </el-form-item>

      <el-form-item label="共病用药需知：" v-if="formModel.themeDrugNotice">
          <vue-neditor-wrap :destroy="false"
                            v-model="formModel.themeDrugNotice.multipleDiseaseNotice"
                            :config="myConfig"></vue-neditor-wrap>

      </el-form-item>

      <el-form-item label="服药时间：" v-if="formModel.themeDrugNotice">
          <vue-neditor-wrap :destroy="false"
                            v-model="formModel.themeDrugNotice.takeDrugTimeNotice"
                            :config="myConfig"></vue-neditor-wrap>

      </el-form-item>

    </el-form>
    <p align="center">
      <el-button type="info"
                 @click="modalClose">取 消
      </el-button>
      <el-button type="primary"
                 @click="submitForm">保 存
      </el-button>
    </p>
  </el-dialog>
</template>
<script>
import {mapGetters} from 'vuex'
import VueNeditorWrap from 'vue-neditor-wrap'
import equipmentDialog from './equipmentDialog' // 推荐器械
import shopDialog from './shopDialog' // 推荐商品
import medicineDialog from './medicineDialog' // 联合荐药
import knowledgeDialog from './knowledgeDialog' // 知识点
import goodsDialog from './goodsDialog'
import ElementTable from "../../../../base/ElementTable"; // 活动商品卖点
export default {
  name: 'themeDialog', // 疾病主题管理
  props: {
    dataObj: {
      type: Object,
      default: {}
    },
    visible: {
      type: Boolean,
      default: false
    },
  },
  data() {
    return {
      myConfig: {
        // 你的UEditor资源存放的路径,相对于打包后的index.html
        UEDITOR_HOME_URL: this.api.uEditorHomeUrl,
        // 编辑器不自动被内容撑高
        autoHeightEnabled: false,
        // 初始容器高度
        initialFrameHeight: '418',
        // 初始容器宽度
        initialFrameWidth: '100%',
        // 关闭自动保存
        enableAutoSave: false,
        scaleEnabled: true
      },
      departments: [],//所属分类
      diseaseList: [],//关联健康地图病种
      title: '新 增',
      loading: false,
      loading1: false,
      loading2: false,

      loading4: false, // 推荐健康风险筛查项目
      loading33: false, // 任选X项
      loading44: false, // 全测指标
      loading55: false, // 相关检测项
      isShowEquipment: false, // 推荐器械
      isShowShop: false, // 推荐商品
      isShowMedicine: false, // 联合荐药
      isShowKnowledge: false, // 知识点
      isShowGoods: false, // 活动商品卖点
      imageUploadUrl: this.api.appUpgradeUpload.url,
      formModel: {
        diseaseClassificationId: '',//所属分类
        themeHealthMapDiseases: [],//关联健康地图病种
        isChronicDisease: 0,//是否为慢病病种

        isSlow: 1,
        type: 1,
        name: '', // 主题名称
        drugDiseaseTypeId: '', // 关联主症
        complicationId: '', // 合并症
        knowledgePoints: '', // 病症知识点
        packageReference: '', // 组合包参考
        themeDeviceDtoList: [], // 必测检测项、相关检测项
        recommendableProjects: '', // 推荐医院检查项目
        themeHealthDtoList: [], // 已选健康筛查项目列表
        apparatusRequestDtoList: [], // 推荐器械列表
        sellDrugDtoList: [], // 推荐商品列表
        recommendMedicineRequestDtoList: [], // 联合荐药列表
        recommendSalesScript: '', // 销售话术
        themeKnowledgeRequestDtoList: [], // 知识点、活动商品卖点
        departmentIds: [], // 科室
        scaleIds: [], // 量表
        recommendReferenceThemes: [], // 慢病
        themeProduct: {
          price: '',
          detectAward: '',
        },
        healthMapDiseaseId:'',
        themeDrugNotice:{
          prevention:'',
          drugRefer:'',
          multipleDiseaseNotice:'',
          takeDrugTimeNotice:'',

        }
      },
      departmentList: [],//科室列表
      scaleList: [],//量表列表
      themeDeviceTable: [],
      themeDeviceTableList1: [], //
      correlationDtoList: [], // 相关检测
      recommendMedicineRequestDtoList: [],
      detectIds: '', // 相关检测项
      everyDetectIds: '', // 全测指标
      someDetectIds: '', // 任选X项
      riskIds: '', // 推荐健康风险筛查项目
      formRules: {
        name: [{required: true, message: '请输入主题名称', trigger: 'blur'}],
        drugDiseaseTypeId: [{required: true, message: '请选择关联主症', trigger: 'chagne'}],
        knowledgePoints: [{required: true, message: '请输入病症知识点', trigger: 'blur'}],
        themeHealthMapDiseases: [{required: true, type: 'array', message: '请选择健康地图病种', trigger: 'blur'}],
        scaleIds: [{required: true, message: '请选择量表', trigger: 'blur'}],
        departmentIds: [{required: true, message: '请选择科室', trigger: 'blur'}],
        'themeProduct.price': [{required: true, message: '请输入产品检测价格', trigger: 'blur'}],
        'themeProduct.detectAward': [{required: true, message: '请输入店员检测费用', trigger: 'blur'}],
      },
      // 必测检测项
      detectList: [],
      detectFilterList: [],
      // 关联主症
      associateList: [],
      associateFilterList: [],
      // 合并症
      complicationList: [],
      complicationFilterList: [],
      // 推荐健康风险筛查项目
      riskList: [],
      riskFilterList: [],
      equipmentDataObj: {}, // 推荐器械
      shopDataObj: {}, // 推荐商品
      medicineDataObj: {}, // 联合荐药
      knowledgeDataObj: {}, // 知识点
      goodsDataObj: {}, // 活动商品卖点
      typeList: [
        {drugType: 2, drugName: "化学药"},
        {drugType: 3, drugName: "中成药"},
        {drugType: 4, drugName: "保健品"},
        {drugType: 5, drugName: "器械"}
      ],
      childMedicineTableData: [],
      knowledgeList: [], // 知识点
      goodsList: [], // 活动商品卖点
      isShowDetail: false,
      maxNum: 1,
      columns: [{
        label: '病种名称',
        prop: 'themeName',
        align: "center",
      }, {
        label: '操作',
        prop: 'option',
        align: 'center',
        isSlot: true,
      }],
      slowList: [],
      defaultProps: {
        label: "themeName",
        children: "children"
      },
      defaultCheckedKeys: []
    }
  },
  methods: {
    modalClose() {
      this.$emit('update:visible', false); // 直接修改父组件的属性
    },
    // 提交
    submitForm() {
      // 必测检测项、相关检测项
      let tempDataList = [];
      this.themeDeviceTable.forEach(item => {
        item.themeDeviceDtoList.forEach(item2 => {
          tempDataList.push(item2);
        });
      });
      this.formModel.themeDeviceDtoList = [...this.themeDeviceTableList1, ...tempDataList, ...this.correlationDtoList];
      if (this.themeDeviceTableList1.length === 0) {
        this.$message.error('必测检测项至少添加一项!');
        return
      }
      this.formModel.themeKnowledgeRequestDtoList = [...this.knowledgeList, ...this.goodsList];
      this.formModel.themeKnowledgeRequestDtoList.forEach(item => {
        if (item.knowledgeImageUrls) {
          item.knowledgeImageUrls = JSON.stringify(item.knowledgeImage);
        }
      })

      this.$refs.formRef.validate((valid) => {
        // 联合荐药
        let recommendMedicine = [];
        this.recommendMedicineRequestDtoList.forEach(item => {
          item.value.forEach(list => {
            recommendMedicine.push(list);
          })
        })
        this.formModel.recommendMedicineRequestDtoList = recommendMedicine;
        if (this.formModel.themeDeviceDtoList.length === 0) {
          this.$message.error('推荐检测项不能为空!');
          return
        }
        // if (this.goodsList.length === 0) {
        //   this.$message.error('重点知识点不能为空!');
        //   return
        // }
        if (valid) {
          // if (this.formModel.isChronicDisease === 1 && this.formModel.recommendReferenceThemes.length === 0) {
          //   this.$message.warning('请选择慢病病种')
          //   return;
          // }
          if (this.formModel.isChronicDisease === 0) {
            this.formModel.recommendReferenceThemes = []
            this.formModel.themeProduct = null
          }
          if (this.dataObj) { // 编辑
            delete this.formModel.complicationNames;
            this.post(this.api.promote.updateDiseaseTheme, this.formModel, {showFullScreenLoading: true}).then(res => {
              if (res.data.code === '200') {
                this.$message.success('保存成功!');
                this.modalClose();
                this.$parent.getList();
              }
            })
          } else { // 新增
            this.post(this.api.promote.saveDiseaseTheme, this.formModel, {showFullScreenLoading: true}).then(res => {
              if (res.data.code === '200') {
                this.$message.success('保存成功!');
                this.modalClose();
                this.$parent.getList();
              }
            })
          }

        }
      })
    },
    handleAdd(option) {
      switch (option) {
        case 'equipment':
          this.isShowEquipment = true;
          break;
        case 'shop':
          this.isShowShop = true;
          break;
        case 'medicine':
          this.isShowMedicine = true;
          let {recommendSalesScript, recommendMedicineRequestDtoList} = this.formModel;
          let data = this.childMedicineTableData;
          this.medicineDataObj = {
            recommendSalesScript: recommendSalesScript,
            recommendMedicineRequestDtoList: data.length === 0 ? recommendMedicineRequestDtoList : data
          };
          break;
        case 'knowledge':
          this.isShowKnowledge = true;
          this.isShowDetail = false;
          break;
        case 'goods':
          this.isShowGoods = true;
          this.isShowDetail = false;
          break;
      }
    },

    delRow(table, index, option) {
      table.splice(index, 1);
    },
    // 推荐器械,接收子组件传递过来的数据
    childEquipmentData(data) {
      this.formModel.apparatusRequestDtoList.push(data);
    },
    // 推荐商品,接收子组件传递过来的数据
    childShopData(data) {
      this.formModel.sellDrugDtoList.push(data);
    },
    // 联合荐药,接收子组件传递过来的数据
    childMedicineData(data) {
      this.childMedicineTableData = data.tableData;
      this.formModel.recommendSalesScript = data.recommendSalesScript;
      const result = this.typeList.map(item => ({
        ...item,
        value: data.tableData.filter(sItem => item.drugType === sItem.drugType)
      }))
      this.recommendMedicineRequestDtoList = result;
    },
    // 知识点,接收子组件传递过来的数据
    childKnowledgeData(data) {
      if (data.isEdit) {
        this.knowledgeList[[data.key]] = data;
      } else {
        this.knowledgeList.push(data);
      }
      this.knowledgeList.forEach(item => {
        item.keyWord = item.keyWordList.join(',');
      })
    },
    // 活动商品卖点,接收子组件传递过来的数据
    childGoodsData(data) {
      if (data.isEdit) {
        this.goodsList[[data.key]] = data;
      } else {
        this.goodsList.push(data);
      }
      this.goodsList.forEach(item => {
        item.keyWord = item.keyWordList.join(',');
      })
    },
    // 删除知识点、活动商品卖点、删除图片
    removeRow(data, index, option) {
      data.splice(index, 1);
    },

    // 编辑知识点、活动商品卖点
    editRow(data, index, option) {
      if (option === 'knowledge') {
        this.isShowKnowledge = true;
        this.isShowDetail = true;
        this.knowledgeDataObj = Object.assign({}, {...data[index], isEdit: true, key: index,});
      }
      if (option === 'goods') {
        this.isShowGoods = true;
        this.isShowDetail = true;
        this.goodsDataObj = Object.assign({}, {...data[index], isEdit: true, key: index,});
      }

    },
    // 远程搜索关联主症、合并症
    remoteMethod(query, op) {
      if (query !== '') {
        let _this = this;
        if (op === 'drugDisease') { // 关联主症
          _this.loading1 = true;
          // this.post(this.api.promote.diseaseList, {
          this.post(this.api.promote.getThemeComplicationList, {
            search: query,
            pageIndex: 0,
            pageSize: 10,
            id: ''
          }).then(res => {
            if (res.data.code === '200') {
              _this.loading1 = false;
              _this.associateList = res.data.object;
            }
          })
          setTimeout(() => {
            _this.loading1 = false;
            _this.associateFilterList = _this.associateList.filter(item => item.name.indexOf(query) > -1);
          }, 200)
        }
        if (op === 'complication') { // 合并症
          _this.loading2 = true;
          this.post(this.api.promote.getThemeComplicationList, {
            search: query,
            pageIndex: 0,
            pageSize: 10,
            id: this.formModel.drugDiseaseTypeId
          }).then(res => {
            if (res.data.code === '200') {
              _this.loading2 = false;
              _this.complicationList = res.data.object;
            }
          })
          setTimeout(() => {
            _this.loading2 = false;
            _this.complicationFilterList = _this.complicationList.filter(item => item.name.indexOf(query) > -1);
          }, 200)
        }

      } else {
        if (op === 'drugDisease') {
          this.associateFilterList = [];
        }
        if (op === 'complication') {
          this.complicationFilterList = [];
        }
      }
    },

    handleSelect(item, op) {
      if (op === 'drugDisease') {
        this.formModel.drugDiseaseTypeId = item;
      }
      if (op === 'complication') {
        if (this.dataObj) {
          this.formModel.complicationIds = [item];
          // this.formModel.complicationId = null;
        } else {
          this.formModel.complicationId = item;
        }
      }
    },


    // ---------远程搜索必测检测项、相关检测项、推荐健康风险筛查项目---------
    remoteMethod2(query, op) {
      if (query !== '') {
        let _this = this;
        if (op === 'everyItem') {
          _this.loading44 = true;
          this.post(this.api.promote.getDeviceList, {
            name: query,
            pageIndex: 0,
            pageSize: 10
          }).then(res => {
            if (res.data.code === '200') {
              _this.loading44 = false;
              _this.detectList = res.data.object;
            }
          })
          setTimeout(() => {
            _this.loading44 = false;
            _this.detectFilterList = _this.detectList.filter(item => item.name.indexOf(query) > -1);
          }, 200)
        }
        if (op === 'someItem') {
          _this.loading33 = true;
          this.post(this.api.promote.getDeviceList, {
            name: query,
            pageIndex: 0,
            pageSize: 10
          }).then(res => {
            if (res.data.code === '200') {
              _this.loading33 = false;
              _this.detectList = res.data.object;
            }
          })
          setTimeout(() => {
            _this.loading33 = false;
            _this.detectFilterList = _this.detectList.filter(item => item.name.indexOf(query) > -1);
          }, 200)
        }
        // 相关检测项
        if (op === 'detect') {
          _this.loading55 = true;
          this.post(this.api.promote.getDeviceList, {
            name: query,
            pageIndex: 0,
            pageSize: 10
          }).then(res => {
            if (res.data.code === '200') {
              _this.loading55 = false;
              _this.detectList = res.data.object;
            }
          })
          setTimeout(() => {
            _this.loading55 = false;
            _this.detectFilterList = _this.detectList.filter(item => item.name.indexOf(query) > -1);
          }, 200)
        }
        // 推荐健康风险筛查项目
        if (op === 'risk') {
          _this.loading4 = true;
          this.post(this.api.promote.getRecommendPageList, {
            name: query
          }).then(res => {
            if (res.data.code === '200') {
              _this.loading4 = false;
              _this.riskList = res.data.object.map(item => ({
                healthCheckPackageId: item.id,
                name: item.name,
                type: item.healthRiskTypeName,
              }));
            }
          })
          setTimeout(() => {
            _this.loading4 = false;
            _this.riskFilterList = _this.riskList.filter(item => item.name.indexOf(query) > -1);
          }, 200)
        }

      } else {
        if (op === 'everyItem') {
          this.detectFilterList = [];
        }
        if (op === 'someItem') {
          this.detectFilterList = [];
        }
        if (op === 'detect') {
          this.detectFilterList = [];
        }
        if (op === 'risk') {
          this.riskFilterList = [];
        }
      }
    },

    handleSelect2(item, op) {
      if (op === 'detect') {
        this.detectIds = item;
      }
      if (op === 'someItem') {
        this.someDetectIds = item;
      }
      if (op === 'risk') {
        this.riskIds = item;
      }
    },
    // 必测检测项-动态添加 任选几项
    handleAddItem(num) {
      this.themeDeviceTable.push({
        modelIndex: num,
        num: undefined,
        themeDeviceDtoList: []
      });
    },
    /*
 * 增加推全测指标、任意几项指标、相关检测项,推荐健康风险筛查项目
 *
 * @param selVal {string} 文件名
 * @param op {string} 操作类型
 * @param index {number} 数组下标
 * @param fillNum {number} 任意几项
 * @param modelIndex {number} 删除后剩下的下标
 */
    handleAddSelectVal(selVal, op, index, fillNum, modelIndex) {
      // 全测指标
      if (op === 'everyItem') {
        if (selVal === '') {
          this.$message.error('请选择推荐检测项!');
          return
        }
        if (this.themeDeviceTableList1.some(item => item.deviceId === selVal)) {
          this.$message.error('推荐检测项不能重复添加!');
          this.everyDetectIds = '';
          return
        }
        this.post(this.api.promote.getReferenceInfo, {deviceId: selVal})
          .then(res => {
            if (res.data.code === '200') {
              let colArr = [['deviceId', 'deviceName', 'delField'], []];
              res.data.object.forEach(item => {
                item.delField = '删除';
                item.bindicator = 1;
                item.modelIndex = 0;
                item.num = 0;
              })
              let resData = res.data.object;
              if (resData.length === 0) {
                this.$message.error('该检测项的检测指标为空,请选择其它检测项目!');
                this.everyDetectIds = '';
                return;
              }
              let temp = [...this.themeDeviceTableList1, ...resData];
              let resTable = this.merge(colArr, temp); // 合并单元格
              this.themeDeviceTableList1 = resTable;
              this.everyDetectIds = '';
            }

          })
      }
      // 任意测几项
      if (op === 'someItem') {
        if (selVal === '') {
          this.$message.error('请选择推荐检测项!');
          return
        }
        if (this.themeDeviceTable[index].themeDeviceDtoList.some(item => item.deviceId === selVal)) {
          this.$message.error('推荐检测项不能重复添加!');
          this.themeDeviceTable[index].someDetectIds = '';
          return
        }
        this.post(this.api.promote.getReferenceInfo, {deviceId: selVal})
          .then(res => {
            if (res.data.code === '200') {
              let colArr = [['deviceId', 'deviceName', 'delField'], []];
              res.data.object.forEach(item => {
                item.delField = '删除';
                item.bindicator = 1;
                item.modelIndex = modelIndex;
                item.num = fillNum;
              })
              let resData = res.data.object;
              if (resData.length === 0) {
                this.$message.error('该检测项的检测指标为空,请选择其它检测项目!');
                this.themeDeviceTable[index].someDetectIds = '';
                return;
              }
              let temp = [...this.themeDeviceTable[index].themeDeviceDtoList, ...resData];
              let resTable = this.merge(colArr, temp); // 合并单元格
              this.themeDeviceTable[index].themeDeviceDtoList = resTable;
              this.themeDeviceTable[index].someDetectIds = '';
            }

          })
      }
      // 相关检测项
      if (op === 'detect') {
        if (selVal === '') {
          this.$message.error('请选择推荐检测项!');
          return
        }
        if (this.correlationDtoList.some(item => item.deviceId === selVal)) {
          this.$message.error('推荐检测项不能重复添加!');
          this.detectIds = '';
          return
        }
        this.post(this.api.promote.getReferenceInfo, {deviceId: selVal})
          .then(res => {
            if (res.data.code === '200') {
              let colArr = [['deviceId', 'deviceName', 'delField'], []];
              res.data.object.forEach(item => {
                item.delField = '删除';
                item.bindicator = 0;
                item.modelIndex = -1;
                item.num = 0;
              })
              let resData = res.data.object;
              if (resData.length === 0) {
                this.$message.error('该检测项的检测指标为空,请选择其它检测项目!');
                this.detectIds = '';
                return;
              }
              let temp = [...this.correlationDtoList, ...resData];
              let resTable = this.merge(colArr, temp); // 合并单元格
              this.correlationDtoList = resTable;
              this.detectIds = '';
            }

          })

      }
      // 已选健康筛查项目
      if (op === 'risk') {
        if (selVal === '') {
          this.$message.error('请选择推荐健康风险筛查项目!');
          return
        }
        if (this.formModel.themeHealthDtoList.some(item => item.healthCheckPackageId === selVal)) {
          this.$message.error('推荐健康风险筛查项目不能重复添加!');
          this.riskIds = '';
          return
        }
        let temp = this.riskList.filter(item => item.healthCheckPackageId == selVal);
        this.formModel.themeHealthDtoList = [...this.formModel.themeHealthDtoList, ...temp];
        this.riskIds = '';

      }
    },
    // 删除已选推荐检测项、已选健康筛查项目
    delRowItem(table, op, index, fillNum) {
      table.splice(index, 1);

    },
    // 删除已选检测项 带合并单元格
    delMergeRow(table, row, op, parentIndex) {
      if (op === 'someItem') {
        this.themeDeviceTable[parentIndex].themeDeviceDtoList = table.filter(item => item.deviceId !== row.deviceId);
      }
      if (op === 'everyItem') {
        this.themeDeviceTableList1 = table.filter(item => item.deviceId !== row.deviceId)
      }
      if (op === 'detect') {
        this.correlationDtoList = table.filter(item => item.deviceId !== row.deviceId)
      }
    },
    changeItemVal(val) {
      this.themeDeviceTable.forEach(item => {
        item.themeDeviceDtoList.forEach(el => {
          el.num = item.num
        })
      })
    },
    // 详情
    getDetail() {
      this.post(this.api.promote.themeDiseaseInfo, {
        id: this.dataObj.id
      }).then(res => {
        if (res.data.code === '200') {
          let resData = Object.assign(this.formModel, res.data.object);

          let colArr = [['deviceId', 'deviceName', 'delField'], []];
          this.formModel = resData;
          if (!this.formModel.packageReference) {
            this.formModel.packageReference = ''
          }
          const result = this.typeList.map(item => ({
            ...item,
            value: resData.recommendMedicineRequestDtoList.filter(sItem => item.drugType === sItem.drugType)
          }))
          this.recommendMedicineRequestDtoList = result;
          resData.themeKnowledgeRequestDtoList.forEach(item => {
            item['keyWordList'] = item.keyWord.split(',');
            if (item.knowledgeImageUrls) {
              this.$set(item, 'knowledgeImage', JSON.parse(item.knowledgeImageUrls));
            }
          })
          this.knowledgeList = resData.themeKnowledgeRequestDtoList.filter(item => item.isImportant === 0);
          this.goodsList = resData.themeKnowledgeRequestDtoList.filter(item => item.isImportant === 1);

          // 回显关联主症
          let {drugDiseaseTypeId, drugDiseaseTypeName} = resData;
          this.formModel.drugDiseaseTypeId = drugDiseaseTypeId;
          this.associateFilterList = [{
            id: drugDiseaseTypeId,
            name: drugDiseaseTypeName
          }]
          // 回显合并症
          if (resData.complicationNames.length > 0) {
            this.formModel.complicationId = resData.complicationNames[0].id;
            this.complicationFilterList = resData.complicationNames;
          }
          resData.correlationDtoList.forEach(item => { // 回显相关检测项
            item.delField = '删除';
          })
          this.correlationDtoList = this.merge(colArr, resData.correlationDtoList);
          resData.bindicatorDtoList.forEach(item => { // 回显必测检测项
            item.themeDeviceDtoList.forEach(el => {
              el.delField = '删除';
            })
            this.merge(colArr, item.themeDeviceDtoList);
          });
          if (resData.bindicatorDtoList.filter(item => item.modelIndex === 0)[0]) {
            this.themeDeviceTableList1 = resData.bindicatorDtoList.filter(item => item.modelIndex === 0)[0].themeDeviceDtoList; // 回显必测检测项 - 全测指标
          }
          this.themeDeviceTable = resData.bindicatorDtoList.filter(item => item.modelIndex !== 0); // 回显必测检测项 - 任选几项
          if (this.themeDeviceTable.length > 0) {
            let len = this.themeDeviceTable.length;
            this.maxNum = this.themeDeviceTable[len - 1]['modelIndex'] + 1;
          }
          this.formModel.recommendReferenceThemes = this.formModel.recommendReferenceThemes.filter(item => item)
          this.defaultCheckedKeys = this.formModel.recommendReferenceThemes.map(item => item.id)

        }
      })
    },
    // 合并行计算
    merge(colArr, list) {
      let allProps = [];
      colArr.forEach((props, index) => {
        allProps.push(...props);
        list = this.getLevel(props, allProps, list);
      });
      return list;
    },
    // 组装层
    getLevel(props, allProps, list) {
      var rowKey = {};
      for (var item of list) {
        let propInfo = this.getPropStr(allProps, item);
        if (rowKey[propInfo.key]) {
          rowKey[propInfo.key].children.push(item);
        } else {
          let obj = propInfo;
          obj.children = [item];
          rowKey[propInfo.key] = obj;
        }
      }
      let info = [];
      for (var key in rowKey) {
        rowKey[key].children.forEach((item, index) => {
          if (index == 0) {
            item = Object.assign(
              item,
              this.getMergeInfo(props, rowKey[key].children.length)
            );
          } else {
            item = Object.assign(item, this.getMergeInfo(props, 0));
          }
          info.push(item);
        });
      }
      return info;
    },
    // 获取合并信息
    getMergeInfo(props, num) {
      let obj = {};
      props.forEach(item => {
        obj[item + "_merge"] = {
          rowspan: num,
          colspan: 1
        };
      });
      return obj;
    },
    // 把属性的值拼接在一起,并和属性的值一起返回。
    getPropStr(props, info) {
      let obj = {};
      let propStr = props.map(item => {
        obj[item] = info[item];
        return info[item];
      });
      obj.key = propStr.toString();
      return obj;
    },

    // 表格合并
    handleSpan({row, column, rowIndex, columnIndex}) {

      if (row[column.property + "_merge"]) {
        return row[column.property + "_merge"];
      } else {
        return {rowspan: 1, colspan: 1};
      }
    },
    //查询分类
    getDiseaseClassificationList() {
      this.post(this.api.promote.getDiseaseClassificationList).then((res) => {
        if (res.data.code === '200') {
          this.departments = res.data.object
        }
      })
    },
    //疾病主题管理未调试
    //查询病种
    getHealthMapDiseaseList() {
      this.post(this.api.healthMap.getHealthMapDiseaseList, {
        pageSize: 100
      }).then((res) => {
        if (res.data.code === '200') {
          this.diseaseList = res.data.object
          this.diseaseList.forEach(item => {
            this.$set(item, 'healthMapDiseaseName', item.name)
            this.$set(item, 'healthMapDiseaseId', item.id)
          })
        }
      })
    },
    //查询科室
    getDepartPageApp() {
      this.post(this.api.department.getDepartPageApp, {
        pageSize: 200
      }).then((res) => {
        if (res.data.code === '200') {
          this.departmentList = res.data.object
        }
      })
    },
    //查询量表
    getScaleAll() {
      this.post(this.api.healthMap.getScaleAll, {
        pageSize: 200
      }).then((res) => {
        if (res.data.code === '200') {
          this.scaleList = res.data.object
        }
      })
    },
    handleCheckChange(obj, selectObj) {
      let checkedNodes = selectObj.checkedKeys;
      checkedNodes = checkedNodes.filter(item => item)
      this.formModel.recommendReferenceThemes = checkedNodes.map(item => ({
        id: item
      }))
    },
    //查询慢病病种
    getTreeList() {
      this.post(this.api.promote.getTreeList, {
        pageIndex: 0,
        pageSize: 100
      }).then(res => {
        if (res.data.code === '200') {
          this.slowList = res.data.object;
        }
      })
    },

  },
  created() {
    if (this.dataObj) {
      this.title = '编 辑';
      this.getDetail();
    }
    this.getDiseaseClassificationList()
    this.getHealthMapDiseaseList()
    this.getDepartPageApp()//查询科室
    this.getScaleAll()//查询量表
    this.getTreeList()
  },
  components: {
    'equipment-dialog': equipmentDialog,
    'shop-dialog': shopDialog,
    'medicine-dialog': medicineDialog,
    'knowledge-dialog': knowledgeDialog,
    'goods-dialog': goodsDialog,
    VueNeditorWrap,
    'element-table': ElementTable,
  },
  computed: {
    ...mapGetters(['fileUpload'])
  }
}
</script>
<style scoped lang="scss">
.avatar-uploader {
  border-radius: 6px;
  cursor: pointer;
  position: relative;
  overflow: hidden;

  /deep/ .el-upload {
    &.el-upload--picture-card {
      width: 98px !important;
      height: 98px !important;
      line-height: 98px !important;
    }

    &:hover {
      border-color: #409eff;
    }
  }

  /deep/ .el-upload-list--picture-card {
    .el-upload-list__item {
      width: 98px;
      height: 98px;
    }
  }
}

.knowledge-box {
  width: 100%;

  .el-timeline-item {
    padding-bottom: 0;

    span {
      padding-right: 10px;
      padding-bottom: 10px;
      border-right: 1px solid #ebeef5;
      width: calc(100% - 150px);
    }
  }

  /deep/ .el-timeline-item__wrapper {
    top: -10px;
    padding-left: 20px;

    .knowledge-main {
      display: flex;
      justify-content: space-between;
      align-items: center;
      border-bottom: 1px solid #ebeef5;
    }

    .el-timeline-item__timestamp.is-bottom {
      margin-top: 0;
    }

    .knowledgeImage-list {
      display: flex;
      flex-wrap: wrap;

      li {
        position: relative;

        .del {
          position: absolute;
          z-index: 1;
          right: 0;
          top: 0;
          font-size: 18px;
          color: #f00;
          cursor: pointer;
          display: inline-block;
        }
      }
    }

    .el-image {
      overflow: unset;
      border: 1px dashed #999;
      margin-right: 10px;
      text-align: center;
      margin-top: 10px;

      img {
        height: 100px;
        width: 100px;
        margin-top: 10px;
      }
    }

    .remove {
      font-size: 20px;
      color: #f00;
      cursor: pointer;
    }
  }
}

.w-500 {
  width: 500px;
}

.table-cell {
  td {
    padding: 3px 10px;
    border-bottom: 1px solid #ebeef5;
    border-right: 1px solid #ebeef5;

    &.first-td {
      border-left: 1px solid #ebeef5;
    }
  }
}

.card-box {
  /deep/ .el-card__header {
    padding: 10px 20px;

    .fill-box {
      font-size: 14px;
      font-weight: bold;
      padding-right: 20px;
    }
  }

  .num {
    width: 100px;

    /deep/ .el-input__inner {
      border: none;
      border-bottom: 1px solid #999;
      border-radius: 0;
      width: 100px;
      color: #f00;
      font-weight: bold;
      text-align: center;
    }
  }
}
</style>
